Repository navigation
fix(functions): send a res.send number as JSON and ignore a second argument, as deployed functions do - #311
Merged
Merged
Conversation
res.send(42) made functions:serve answer 500 because Express treats a number as a deprecated status argument. Deployed functions send the number as the body with a 200 status, so convert a number to its string before Express sees it.
…umber
Forward every argument to Express's send and convert only a lone number,
so res.send(404, 'x') and res.send('x', 404) keep their status. Record the
res.redirect and res.send(number) behaviour in the approved V1 differences.
…gument Deployed functions (lambda-node-bridge, the same helpers as Vercel's @vercel/node) take one argument in res.send and send a number through json(): res.send(42) answers 200 with 42 as application/json, NaN as null, and res.send(404, 'x') ignores the 'x'. Match that instead of sending the number as text/html and honouring Express's two-argument forms, and correct the approved V1 differences in AGENTS.md.
The res.send note in AGENTS.md is prose; Talisman flags its punctuation as low-severity patterns. No credentials.
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
🔒 Security Scan Results
⏱️ SLA Breach Summary
ℹ️ Vulnerabilities Without Available Fixes (Informational Only)The following vulnerabilities were detected but do not have fixes available (no upgrade or patch). These are excluded from failure thresholds:
✅ BUILD PASSED - All security checks passed |
naeem-shakh-cs
approved these changes
Nov 26, 2026
dhruv-parekh-cs
approved these changes
Nov 26, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What was wrong
In
launch:functions:serve,res.send(42)answered 500. Express 4 treats a lone number as a deprecated status argument; 42 is not a valid status, sowriteHeadthrows and the route answers 500.Deployed AWS functions (
lambda-node-bridge/cf-sv-with-helpers.tsin contentfly-deployment-agent) use the samesend/jsonhelpers as Vercel's@vercel/node(checked in 33.0.0; even theres.redirect307 default and its error message match word for word). Theirres.sendtakes one argument, and a number goes throughjson():res.send(42)42,application/json; charset=utf-8res.send(NaN)null, JSONNaN*res.status(201).send(418)418, JSONres.send(7)text/plain; charset=utf-8),7res.send(404, 'x')404, JSON (second argument ignored)xres.send('x', 410)x,text/htmlx* NaN is not a valid status either, so Express 4 throws on it too.
The ticket owner chose this exact parity over keeping Express's two-argument forms.
The change
src/functions/cloud-functions.ts: thesendLikeDeployedFunctionsmiddleware replacesres.sendwith a one-argument version: a number goes to Express'sres.json(JSON.stringify,application/jsonunless a content type is already set, current status), and everything else goes to Express'ssendwith only its first argument.AGENTS.md: the approved V1 differences now describeres.sendandres.redirect, and what Azure/GCP (V1, Express 4) still do:res.send(404)as a 404 status,res.send(42)as 500, and the two-argument forms honoured..talismanrc: refreshed checksums forcloud-functions.test.tsandAGENTS.md(test code and prose, no credentials).Tests
src/functions/cloud-functions.test.ts: two regression tests. The number cases (42, 0, status 201 + 418, NaN, a preset content type) failed with 500 before the fix. The second-argument cases failed with Express's 404/410.E2E (http-sanity cloud-functions checks, AWS expectations)
Ran every check in
contentfly-e2e-testsfixtures/http-sanity-cloud-functions.jsonagainstlaunch:functions:servebuilt from each side, servingfixtures/http-sanity-cloud-functions:res.send(number) sends the numbernow passes; no other check changed.No e2e change is needed: the check already exists, and its Azure/GCP
knownGapsentry (500) stays until those clouds run the v2 CLI.Known gaps
res.jsonstill accepts Express 4's two-argument forms locally (res.json(404, body)sets 404), while deployed AWS/Vercelres.jsontakes one argument. This was there before this PR and is outside gap 3; added to CL-8970's gap list as a follow-up.Notes
--no-verify. ggshield is not installed in this environment, so its new hook step printed its skip notice.QA: the Launch QA agent tests CL-8970 in the repos once it is in QA; GoCD sanity covers dev11.
Jira: https://contentstack.atlassian.net/browse/CL-8970